<template>
    <div>
        <ul class="mui-table-view">
            <li v-for="item in newList" :key="item.id" class="mui-table-view-cell mui-media">
                <router-link :to="'/news/info/' + item.id">
                    <img class="mui-media-object mui-pull-left" :src="item.img_url">
                    <div class="mui-media-body">
                        <h1>{{item.title}}</h1>
                        <p class='mui-ellipsis'>
                            <span>Publish At: {{item.add_time}}</span>
                            <span>Hits:{{item.click}}</span>
                        </p>
                    </div>
                </router-link>
            </li>


        </ul>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
export default {
    data:function () {
        return {
            newList:[]
        }
    },
    created:function(){
        this.getNewsList()
    },
    methods:{
        getNewsList(){
            this.$http.get('/news-list').then(res => {
                if (res.body.code == 200){
                    this.newList = res.body.data
                    console.log(res.body)
                }
                else{
                    Toast(res.body.message);
                }
            })
        }
    }
}
</script>

<style lang="less">
.mui-table-view{
    li{
        h1{
            font-size: 14px;
        }
        .mui-ellipsis{
            font-size: 12px;
            color: #226aff;
            display: flex;
            justify-content: space-between;
        }
    }

}
</style>